function numerico(){
	return "0123456789";
}
function decimal(){
	return "0123456789.";
}
function esTeclaEspecial(e){
	var BACKSPACE=8;
	var SUPR=46;
	var TAB		=9;
	var ENTER	=13;
	var CTRL	=17;
	var ALT		=18;
	var C	=99;
	var V	=118;
	var X	=120;
	
	var code = (e.keyCode ? e.keyCode : e.which);
	if((code >= 35 && code < 39) 
			|| code == BACKSPACE
			|| code == SUPR
			|| code == TAB
			|| code == ENTER
			|| code == CTRL
			|| code == ALT
			|| (e.ctrlKey && code == C)
			|| (e.ctrlKey && code == V)
			|| (e.ctrlKey && code == X)){return true;}
	if(code==39){
		var k = String.fromCharCode(e.which);
		if(k=="'"){return false;}
		else {return true;}
	}
	return false;
}
function esTeclaEspecialBorrar(e){
	var TAB		=9;
	var ENTER	=13;
	var CTRL	=17;
	var ALT		=18;
	var C	=99;
	var V	=118;
	var X	=120;
	
	var code = (e.keyCode ? e.keyCode : e.which);
	if((code >= 35 && code < 39) 
			|| code == TAB
			|| code == ENTER
			|| code == CTRL
			|| code == ALT
			|| code == 16
			|| (e.ctrlKey && code == C)
			|| (e.ctrlKey && code == V)
			|| (e.ctrlKey && code == X)
			|| (e.shiftKey && code == 37)
			|| (e.shiftKey && code == 39)){return true;}
	if(code==39){
		var k = String.fromCharCode(e.which);
		if(k=="'"){return false;}
		else {return true;}
	}
	return false;
}
function tamano(e,cod){
	var cadenaAnt = $(cod).val();
	if($(cod).attr("id")!=null){
		var tamId = $(cod).attr("id").split(",");
		var longitud;
			if(tamId.length==2){
				longitud=tamId[1];
				if(cadenaAnt.length>=longitud){
					e.preventDefault();
				}
			}
	}
}
function aplicarValidaciones(){
	$(".entero").numeric(false);
	$(".decimal").numeric(","); 
	$(".decimal2").numeric(",");
}

$(document).ready(function() {
	
	$(".entero").numeric(false);
	$(".decimal").numeric(","); 
	$(".decimal2").numeric(",");
	
	$("body").delegate(".textarea","keypress", function(e) {
		tamano(e,this);
	});
	
	
});